package com.itheima.tanhua.api;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.tanhua.api.db.QuestionServiceApi;
import com.itheima.tanhua.mapper.QuestionsMapper;
import com.itheima.tanhuan.pojo.db.Question;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class QuestionsServiceApiImpl implements QuestionServiceApi {
    @Autowired
    QuestionsMapper questionsMapper;

    @Override
    public String strangerQuestions(Long userId) {
        //根据用户id返回问题
        LambdaQueryWrapper<Question>wrapper=new LambdaQueryWrapper<>();
        wrapper.eq(Question::getUserId,userId);
        List<Question> question = questionsMapper.selectList(wrapper);
        if (ObjectUtil.isEmpty(question)){
            return "你喜欢java吗？";
        }
        String questionlist=null;
        for (Question question1 : question) {
            questionlist+=question1.getTxt();
        }
        return questionlist;
    }
}
